package com.spark.modules.generation.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spark.modules.generation.entity.GenConfig;
import com.spark.modules.generation.mapper.GenConfigMapper;
import com.spark.modules.generation.service.IGenConfigService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * 代码生成配置Service
 *
 * @author LYCHEE
 * @date 2025/02/28 15:05
 */
@Service
public class GenConfigServiceImpl extends ServiceImpl<GenConfigMapper, GenConfig> implements IGenConfigService {

    /**
     * 获取配置
     *
     * @return 配置
     */
    @Override
    public GenConfig getConfig() {
        List<GenConfig> genConfigs = baseMapper.selectList(new QueryWrapper<>());
        if (!CollectionUtils.isEmpty(genConfigs)) {
            return genConfigs.get(0);
        }
        return null;
    }
}
